﻿using System.Collections.Generic;

namespace Cms.Domain.Comparers
{
    public class AdministratorGroupNameComparer : IComparer<AdministratorGroup>
    {
        private readonly SortDirection _sortDirection;

        public AdministratorGroupNameComparer(SortDirection sortDirection)
        {
            _sortDirection = sortDirection;
        }

        #region IComparer<AdministratorGroup> Members

        public int Compare(AdministratorGroup x, AdministratorGroup y)
        {
            int result = 0;
            result = string.Compare(x.Name, y.Name);
            return _sortDirection == SortDirection.Ascending ? result : result * -1;
        }

        #endregion
    }
}